//
//  QTTXWBTAlertView.m
//  QuTouTiao
//
//  Created by 杨杨子 on 2018/6/26.
//  Copyright © 2018年 杨杨子. All rights reserved.
//

#import "QTTXWBTAlertView.h"
@interface QTTXWBTAlertView()
@property (weak, nonatomic) IBOutlet UIView *backView;
@property (weak, nonatomic) IBOutlet UIImageView *leftImageView;
@property (weak, nonatomic) IBOutlet UILabel *tittleLb;
@property (weak, nonatomic) IBOutlet UIButton *leftBtn;
- (IBAction)leftBtnAction:(id)sender;
@property (weak, nonatomic) IBOutlet UIButton *rightBtn;
- (IBAction)rightBtnAction:(id)sender;
@property (nonatomic,strong) ActionBlock leftBlock;
@property (nonatomic,strong) ActionBlock rightBlock;
@end
@implementation QTTXWBTAlertView

-(void)awakeFromNibAndTittle:(NSString *)tittle AndLeftImageName:(NSString *)imageName AndLeftBtnStr:(NSString *)leftStr AndRightStr:(NSString *)rightStr AndLeftBlock:(ActionBlock)leftBlock AndRightBlock:(ActionBlock)rightBlock AndFatherView:(UIView *)fatherView{
    [super awakeFromNib];
    self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    [self.backView setCornerRadius:10.0 AndBorderColor:[UIColor blackColor] AndBorderWidth:1.0];
    self.backView.backgroundColor = [UIColor whiteColor];
    self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.2];
    self.leftImageView.image = [UIImage imageNamed:imageName];
    self.tittleLb.text = tittle;
    [self.leftBtn setTitle:leftStr forState:UIControlStateNormal];
    [self.rightBtn setTitle:rightStr forState:UIControlStateNormal];
    self.leftBlock = leftBlock;
    self.rightBlock = rightBlock;
    [fatherView addSubview:self];
    __weak typeof (self) weakSelf = self;
    [self viewTapBlock:^{
        [weakSelf removeFromSuperview];
    }];
}
- (IBAction)leftBtnAction:(id)sender{
    [self removeFromSuperview];
    if (self.leftBlock) {
        self.leftBlock();
    }
}
- (IBAction)rightBtnAction:(id)sender{
    [self removeFromSuperview];
    if (self.rightBlock) {
        self.rightBlock();
    }
}

@end
